package captor.windowsystem.formcomponent.ncp.fcomponentpanel;

import javax.swing.JComboBox;

public class ShortNameCombo extends JComboBox{

	private static final long serialVersionUID = 919070331382629134L;

	@Override
	public Object getItemAt(int index){
		Object result = super.getItemAt(index);
		String shortName = (String) result;
		if (shortName!=null){
			String fullname =  shortName.replaceAll("\\.\\.\\.", "captor.windowsystem.formcomponent.");
			return fullname;
		}
		return result;
	}
		
	@Override
	public void addItem(Object anObject){
		String fullname = (String) anObject;
		if (fullname!=null){
			String shortName = fullname.replaceAll("captor.windowsystem.formcomponent", "..");
			super.addItem(shortName);
		}
		else{
			super.addItem(anObject);
		}
		
	}
	
	@Override
	public Object getSelectedItem(){		
		Object result = super.getSelectedItem();
		String shortName = (String) result;
		if (shortName!=null){
			String fullname =  shortName.replaceAll("\\.\\.\\.", "captor.windowsystem.formcomponent.");
			return fullname;	
		}
		return result;
	}
}
